package com.example.lottery.controller;


import com.example.lottery.bean.ParameterCalibration;
import com.example.lottery.enums.Message;
import com.example.lottery.req.OriginalDataRequest;
import com.example.lottery.res.BettingDataResponse;
import com.example.lottery.service.DataProcessingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 投注数据 前端控制器
 * </p>
 *
 * @author tanwei
 * @since 2024-03-01
 */

@Api(tags = "投注数据")
@RestController

@RequestMapping("/dbBettingData")
public class DbBettingDataController {

    @Autowired
    private DataProcessingService dataProcessingService;

    @ApiOperation(value = "投注查询")
    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public Message<List<BettingDataResponse>> findAll() {
        List<BettingDataResponse> data = dataProcessingService.findByBettingData();
        return new Message<List<BettingDataResponse>>().setData(data);
    }

    @ApiOperation(value = "处理数据")
    @ParameterCalibration
    @RequestMapping(value = "/handleData", method = RequestMethod.POST)
    public Message<List<BettingDataResponse>> handleData( @RequestBody OriginalDataRequest request) {
        dataProcessingService.dataProcessing(request);
        return new Message<List<BettingDataResponse>>().setData(null);
    }

    @ApiOperation(value = "重置数据")
    @RequestMapping(value = "/resetData", method = RequestMethod.GET)
    public Message resetData() {
        dataProcessingService.resetData();
        return new Message<List<BettingDataResponse>>().setData(null);
    }

}

